<?php /* Smarty version Smarty-3.0.6, created on 2018-04-13 23:32:18
         compiled from "E:/xiangmu/phpstudy/WWW/chenjin/dingwei/temp/default\index.htm" */ ?>
<?php /*%%SmartyHeaderCode:7015ad0cd82959475-94097506%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '56bfe63fe05762a03c7e841cd1f536b6844dbc70' => 
    array (
      0 => 'E:/xiangmu/phpstudy/WWW/chenjin/dingwei/temp/default\\index.htm',
      1 => 1523633311,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '7015ad0cd82959475-94097506',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/temp/default/js/jquery-3.1.0.min.js"></script>
    <script src="/temp/default/js/flexible.debug.js"></script>
    <script src="/temp/default/js/flexible_css.debug.js"></script>
    <link rel="stylesheet" href="/temp/default/css/index.css">
    <title>福利大抽奖</title>
</head>
<body>
    <div class="container">
        <p class="label">填写分享信息，吸引好友打开你分享的消息！</p>
        <input type="text" id="title" placeholder="分享标题例如:kaki送你一次免费抽奖活动" />
        <input type="text" id="desc" placeholder="分享的描述,至少6-12个字，越完善越有诱惑性" />
        <p class="label">试试上传一张照片作为分享分享的图标</p>
        <div class="upload">
            <form id="upfile" enctype="multipart/form-data" method="post">
                <input type="file" name="upload_name" id="upload" />
                <img id="img" src="/temp/default/image/upload.png" alt=""/>
                <input type="hidden" id="images" />
            </form>
        </div>
        <p class="infer">
            提示：<br/>
            1、输入分享标题和分享描述即可分享好友，图标不上传默认红包图标<br/>
            2、直接发送好友即可，也可以发送到朋友圈<br/>
            3、默认提供红包分享图标
        </p>
    </div>
</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
    host = window.location.host;
    var title = $('#title').val() ? $('#title').val() : "抢红包";
    var desc = $('#desc').val() ? $('#desc').val() : "快点抢红包啊";
    var url = $('#img').attr('src');
    if(!url){
        url = host+"temp/default/image/hongbao.png";
    }else{
        url = host+url;
    }
    wx.config({
        debug: false,
        appId: '<?php echo $_smarty_tpl->getVariable('signPackage')->value['appId'];?>
',
        timestamp:'<?php echo $_smarty_tpl->getVariable('signPackage')->value['timestamp'];?>
',
        nonceStr: '<?php echo $_smarty_tpl->getVariable('signPackage')->value['nonceStr'];?>
',
        signature: '<?php echo $_smarty_tpl->getVariable('signPackage')->value['signature'];?>
',
        jsApiList: [
            // 所有要调用的 API 都要加到这个列表中
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
        ]
    });
    wx.ready(function(){
        wx.onMenuShareTimeline({
            title:title, // 分享标题
            link: 'http://dingwei.famishare.me/', // 分享链接
            imgUrl:url, // 分享图标
            desc:desc,
            success: function () {
                // 用户确认分享后执行的回调函数
                //  alert("分享成功");
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
        wx.onMenuShareAppMessage({
            title: title,
            desc:desc,
            link: 'http://dingwei.famishare.me/', // 分享链接
            imgUrl: url, // 分享图标
            type: '', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () {
                // 用户确认分享后执行的回调函数
                //  alert("分享成功");
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });


    })




    $("#upload").change(function (e) {
        var file = e.target.files[0];
        var formData = new FormData();
        formData.append("file",file)
        $.ajax({
            url: "api/upload.php",
            type: "POST",
            processData: false,
            contentType: false,
            data: formData,
            success: function(data) {
                data = JSON.parse(data);
                if(data.file_path){
                    $("#img").attr("src", data.file_path);
                    $('#image').val(data.file_path);
                }else{
                    alert(data);
                }
            }
        });
    });
</script>
</html>